import moment from 'moment'
export default {
  codeDefault: {
    data: {},
    code: 0,
    status: 1,
    msg: ''
  },
  resError(opt) {
    return {...this.codeDefault,status:0,...opt};
  },
  resSuccess(opt) {
    return {...this.codeDefault,...opt}
  },
  getDateObj(){
    let dateObj = moment().toObject();
    dateObj.months = ++dateObj.months<10?`0${dateObj.months}`:dateObj.months;
    //  dateObj.months<10?`0${dateObj.months}`:dateObj.months;
    return dateObj;
  },
  getDateDir(type="date"){
    let dateObj = this.getDateObj();
    if(type == 'date'){
      return `${dateObj.years}/${dateObj.months}/${dateObj.date}/`
    }else{
      return `${dateObj.years}/${dateObj.months}/`
    }
    
  },
  createNoncestr(){
    return Math.random().toString(36).substr(2,15)
  },
  getTimeString(){
    return moment().unix();
  }
}